<?php


class Draft
{
	public $id;
	public $name;
	public $teamNumber;
	public $currentRound;
	public $currentPick;
	
	public function __construct($id, $name, $teamNumber)
	{
		$this->id = $id;
		$this->name = $name;
		$this->teamNumber = $teamNumber;
		//$this->currentRound = 1;
		//$this->currentPick = 1;
	}
	
	public function isOnClock($draftOrder)
	{
		if ($this->currentRound % 2 == 0) //even round
		{
			return $this->teamNumber - (($this->currentPick-1) % $this->teamNumber) == $draftOrder;
		}
		else //odd round
		{
			return ($this->currentPick - 1) % $this->teamNumber + 1 == $draftOrder;
		}
		
		
	}
	
	public function currentDraftOrder()
	{
		if ($this->currentRound % 2 == 0) //even round
		{
			return $this->teamNumber - (($this->currentPick-1) % $this->teamNumber);
		}
		else //odd round
		{
			return ($this->currentPick - 1) % $this->teamNumber + 1;
		}
		
	}
	
	public function increment()
	{
		$this->currentPick = ++$this->currentPick;
		if (($this->currentPick - 1) % $this->teamNumber == 0)
		{
			$this->currentRound = ++$this->currentRound;
			if ($this->currentRound > 16)
			{
				return false;
			}
		}
		return $this;
	}
	
	public function __toString()
	{
		return $this->name;
	}
}



?>